﻿
; TestController must be restarted before any changes in this file will be used.

; Manual is here: https://lygte-info.dk/project/TestControllerConfigDevice%20UK.html

#idString Metrix,MTX3291
#name Metrix MTX3291
#handle MTX3291
#port comfixedbaud
; Alternate port types: comnobaud or com, com lets the user define baudrate on the "Load devices" page
#baudrate 9600
#driver SCPIx

#eol \r\n

#notes The protocol implementation in the meter is buggy and slow.

#scpiCmd *IDN? txrx? *IDN?
:readmath: "Metrix,"+getElement(value,0,",")+","+","+getElement(value,1,",")+" "+getElement(value,2,",")

;° symbol is using UTF8, but µ symbol is not. If a software update in the meter fixes this to use UTF8 for both enable this line.
;#charset UTF-8

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6) 
; Format: #value ColumnName Unit Format {Selector}
; Selector is only used when column layout varies with mode, this often require the use of #cmdMode
#value Voltage V SI VOLT,Voltage,Voltage_LowZ,VLOWZ,DIODE,Diode,
#value Decibel dBm D1 DBM,dBm
#value Power_In_R Watt D3 PUISSANCE,VOLTAMP,Power_in_R
#value Frequency Hz D4 FREQUENCY,Frequency
#value Resistance Ohm SI RESISTANCE,Resistance,CONTINUTY,Continuity
#value Current A SI CURRENT,Current,Clamp
#value Temperature °C D1 TEMPERATURE,Temperature
#value Capacitance F SI CAPACITOR,Capacitance
#value Duty_cycle % d2 Duty_Cycle_+,Duty_Cycle_-
#value Pulse_width ?s SI Pulse_Width_+,Pulse_Width_-
;For pulse width the meter do not report if the unit is ms or us when using the "meas?" command

#cmdModeLayout 4 4

#cmdMode Voltage VOLT
sens:func "VOLTAGE";[150]

#cmdMode Voltage_LowZ VLOWZ
sens:func "VLowZ";[150]

#cmdMode dBm DBM
sens:func "DBM";[150]

#cmdMode Power_in_R PUISSANCE
sens:func "VOLTAMP";[150]

#cmdMode Current CURRENT
sens:func "CURRENT";[150]

#cmdMode Clamp CURRENT
sens:func "CLAMP";[150]

#cmdMode Capacitance CAPACITI
sens:func "CAPACITOR";[150]


#cmdMode Frequency FREQUENCY
sens:func "FREQUENCY";[150]

#cmdMode Duty_Cycle_+ POSITIVE_DUTY
sens:func "POSD";[150]

#cmdMode Duty_Cycle_- NEGATIVE_DUTY
sens:func "NEGD";[150]

#cmdMode Pulse_Width_+ POSITIVE_PULSE
sens:func "POSP";[150]

#cmdMode Pulse_Width_- NEGATIVE_PULSE
sens:func "NEGP";[150]

#cmdMode Resistance RESISTANCE
sens:func "RESISTANCE";[150]

#cmdMode Diode DIODE
sens:func "DIODE";[150]

#cmdMode Continuity CONTINUITY
sens:func "CONTINUITY";[150]

#cmdMode Temperature TEMPERATURE
sens:func "TEMPERATURE";[150]



; How to poll for data, this is used for table and #values?
; a #askMode, #cmdMode and #prepareSample is used before this is string is used.
; Number of returned values must match number of columns defined with #value
; This is a single line command
#askValues MEAS?
#askValuesMathFormat substring(value,0,2)=="--"?0:value


; Format of answer: f=float, u=remove trailing letters, x=skip, *=Zero upper case values if this value is 0
;#askValuesReadFormat 

; Accept this delay when reading values (seconds)
#readingDelay 2

; Mode change have a longer delay on reading values (seconds)
#modeChangeDelay 5

#cmdDelayTime 30

; String to ask about actual meter mode, it is mostly used for DMM's
; This is a single line command
#askMode [150];sens:func?
#askModeMathFormat match(value,"(POSITIVE|NEGATIVE).*")?replace(value," ","_"):getElement(value,0);


; When one of these commands are used through the command interface a new configuration will be done before using #askMode
; Only one word for each #mayModifyMode
; Specify command without initial colon and in the shortest possible form
;#mayModifyMode 


; Prepare the meter to response to #askValues
;#prepareSample arm:sour imm;:arm:count 1;:trig:sour imm;:trig:count 1;:trig:samp:count 1;init

; Initial commands to meter when establishing connection, used to disable local control
;#initCmd  

; Final command to meter before breaking connection, used to restore local control
#finalCmd SYST:LOC

; Used to turn output off for power supplies, generators and electronic loads
;#outputOff 

#interfaceType DMM
#interface readValue 0


#cmdSetup radio Coupling Voltage
:read: [150];INP:COUP?
:write: INP:COUP
:string:
:update: Filter
AC AC
DC DC
AC+DC ACDC

#cmdSetup checkbox Filter Voltage
:read: [150];FILT?
:readmath: listIndex(value,"OFF ON");
:write: FILT 
on 0 1

#cmdSetup checkbox Auto_range Voltage
:read: [150];sense:range:auto?
:readmath: listIndex(value,"Manual Auto");
:write: sense:range:auto
:update: Range
on 0 1

#cmdSetup radio Range Voltage
:read: [150];sense:range?
:readmath: getElement("0.06 0.6 6.0 60.0 600.0 1000.0",value);
:write: sense:range
:enable: Voltage.Auto_range.on==0
60mV 0.06
600mV 0.6
6V 6.0
60V 60.0
600V 600.0
1000V 1000.0


#cmdSetup radio Coupling Current
:read: [150];INP:COUP?
:write: INP:COUP
:update: Filter
:string:
AC AC
DC DC
AC+DC ACDC

#cmdSetup checkbox Filter Current
:read: [150];FILT?
:readmath: listIndex(value,"OFF ON");
:write: FILT 
on 0 1

#cmdSetup checkbox Auto_range Current
:read: [150];sense:range:auto?
:readmath: listIndex(value,"Manual Auto");
:write: sense:range:auto
:update: Range
on 0 1

#cmdSetup radio Range Current
:read: [150];sense:range?
:readmath: getElement("0.6e-3 6e-3 60e-3 600e-3 6 10",value);
:write: sense:RANGE
:enable: Current.Auto_range.on==0
600uA 0.6e-3
6mA 6e-3
60mA 60e-3
600mA 600e-3
6A 6
10A 10

#cmdSetup checkbox Auto_range Resistance
:read: [150];sense:range:auto?
:readmath: listIndex(value,"Manual Auto");
:write: sense:range:auto
:update: Range
on 0 1


#cmdSetup radio Range Resistance
:read: [150];RANGE?
:readmath: getElement("600 6e3 60e3 600e3 6e6 60e6",value);
:write: RANGE
:enable: Resistance.Auto_range.on==0
600ohm 600
6kohm 6e3
60kohm 60e3
600kohm 600e3
6Mohm 6e6
60Mohm 60e6



#cmdSetup checkbox Auto_range Capacitance
:read: [150];sense:range:auto?
:readmath: listIndex(value,"Manual Auto");
:write: sense:range:auto
:update: Range
on 0 1

#cmdSetup radio Range Capacitance
:read: [150];RANGE?
:readmath: getElement("6e-9 60e-9 600e-9 6e-6 50e-6 600e-6 6e-3 60e-3",value);
:write: RANGE
:enable: Capacitance.Auto_range.on==0
;The 60uF range uses 50uF as selector, probably due to rounding errors in the DMM
6nF 6e-9
60nF 60e-9
600nF 600e-9
6uF 6e-6
60uF 50e-6
600uF 600e-6
6mF 6e-3
60mF 60e-3


#cmdSetup radio Sensor Temperature
:read: [150];TEMP:TRAN?
:write: TEMP:TRAN
:string:
RTD_PT100 PT100
RTD_PT1000 PT1000


#cmdSetup radio Impedance dBm
:read: [150];MENU:DBM:IMP?
:write: MENU:DBM:IMP (listIndex(value,"50 75 90 600"))
50ohm 50
75ohm 75
90ohm 90 
600ohm 600


#cmdSetup radio Coupling Power
:read: [150];INP:COUP?
:write: INP:COUP
:string:
AC AC
DC DC
AC+DC ACDC

#cmdSetup number Impedance Power
:read: [150];MENU:WATT:IMP?
:write: MENU:WATT:IMP
:tip: Meter supports up to megaohm, but protocol is missing the exponent, i.e. only meter display will show correct values above 999ohm
ohm 0.1 60.1e6


#cmdSetup radio Ratio Clamp
:read: [150];CLAM:COEF?
:write: CLAM:COEF
1mV/A 1
10mV/A 10
100mV/A 100
1V/A 1000

#cmdSetup radio Coupling Clamp
:read: [150];INP:COUP?
:write: INP:COUP
:string:
AC AC
DC DC
AC+DC ACDC

#cmdSetup checkbox Auto_range Clamp
:read: [150];sense:range:auto?
:readmath: listIndex(value,"Manual Auto");
:write: sense:range:auto
:update: Range
on 0 1

#cmdSetup radio Range Clamp
:read: [150];sense:range?
:readmath: getElement("600e-3 6 60 600 6000",value==""?0:value);
:write: sense:RANGE
:enable: Clamp.Auto_range.on==0
600mA 600e-3
6A 6
60A 60
600A 600
6000A 6000




#cmdSetup Selector No_settings Main
:read: [150];sens:func?
:readmath: match(value,".*CLAMP.*")?"CURRENT_CLAMP":getElement(value,0);
:updatemodechange:
VOLT Voltage.
VLOWZ Voltage.
DBM dBm.
PUISSANCE Power.
VOLTAMP Voltage.
CURRENT Current.
FREQUENCY Frequency.
RESISTANCE Resistance.
TEMPERATURE Temperature.
CAPACITY Capacitance.
CONTINUITY Continuity.
DIODE Diode.
DIODEZ Diode_high_Volt. 
CURRENT_CLAMP Clamp.
;POSITIVE_DUTY DutyCycle
;NEGATIVE_DUTY DutyCycle
;POSITIVE_PULSE PulseWidth
;NEGATIVE_PULSE PulseWidth



